__author__ = 'amin'
import re
import Feature
class Parser():
    def __init__(self, file):
        raw_data = open(file,"r")
        self.data = raw_data.read().replace("\n","").split(">")
        self.data.remove(self.data[0])

    def process(self):
        output=[]
        for line in self.data:
            m=re.search("(\w+)\s\w+\=(\w+)\s\w+\=(\w+)\s\w+\=(\w+)\s\w+\=(\w+)", line)
            if m is not None:
                if m.group(5) == "n":
                    f = Feature.Feature(m.group(1), m.group(2), m.group(4), m.group(3), m.group(5))
                else:
                    f = Feature.Feature(m.group(1), m.group(2), m.group(3), m.group(4), m.group(5))
                output.append(f)
        return output



